package bairui.international.console.web.controller.authority.authorization.role;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.service.Service_Role;


/**
 *
 * 权限管理
 *
 * @generated
 * 
 * @see Test_C_Admin_Authority_Authorization_Role_Authority_ActionAdd 测试
 *
 */
@Controller
public class C_Admin_Authority_Authorization_Role_Authority_ActionAdd
 extends SC_Admin_Authority_Authorization_Role_Authority_ActionAdd 
{

	@Autowired @Lazy private Service_Role service_Role;
	
	/**
	 * 添加权限Action
	 */
	@Action(ActionAdd.class)
	@PutMapping(ActionAdd.RequestMappingValue)
	public @FomatOutput @ResponseBody Object actionAdd(
		ModelMap map, HttpServletRequest request, 
		@PathVariable(name=ActionAdd.PathVariableName.RoleId) long roleId,
		Long[] actionsId
	) throws Exception {
		if(null != actionsId && actionsId.length>0){
			service_Role.addAuthorities(roleId, Arrays.asList(actionsId));
		}
		return null;
	}
	

}


